home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / management / MBeanPermission.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  8.4 KB  |  430 lines

  1. package javax.management;
  2.  
  3. import java.io.IOException;
  4. import java.io.ObjectInputStream;
  5. import java.security.Permission;
  6.  
  7. public class MBeanPermission extends Permission {
  8.    private static final long serialVersionUID = -2416928705275160661L;
  9.    private static final int AddNotificationListener = 1;
  10.    private static final int GetAttribute = 2;
  11.    private static final int GetClassLoader = 4;
  12.    private static final int GetClassLoaderFor = 8;
  13.    private static final int GetClassLoaderRepository = 16;
  14.    private static final int GetDomains = 32;
  15.    private static final int GetMBeanInfo = 64;
  16.    private static final int GetObjectInstance = 128;
  17.    private static final int Instantiate = 256;
  18.    private static final int Invoke = 512;
  19.    private static final int IsInstanceOf = 1024;
  20.    private static final int QueryMBeans = 2048;
  21.    private static final int QueryNames = 4096;
  22.    private static final int RegisterMBean = 8192;
  23.    private static final int RemoveNotificationListener = 16384;
  24.    private static final int SetAttribute = 32768;
  25.    private static final int UnregisterMBean = 65536;
  26.    private static final int NONE = 0;
  27.    private static final int ALL = 131071;
  28.    private String actions;
  29.    private transient int mask;
  30.    private transient String classNamePrefix;
  31.    private transient boolean classNameExactMatch;
  32.    private transient String member;
  33.    private transient ObjectName objectName;
  34.  
  35.    private void parseActions() {
  36.       if (this.actions == null) {
  37.          throw new IllegalArgumentException("MBeanPermission: actions can't be null");
  38.       } else if (this.actions.equals("")) {
  39.          throw new IllegalArgumentException("MBeanPermission: actions can't be empty");
  40.       } else {
  41.          int var1 = getMask(this.actions);
  42.          if ((var1 & 131071) != var1) {
  43.             throw new IllegalArgumentException("Invalid actions mask");
  44.          } else if (var1 == 0) {
  45.             throw new IllegalArgumentException("Invalid actions mask");
  46.          } else {
  47.             this.mask = var1;
  48.          }
  49.       }
  50.    }
  51.  
  52.    private void parseName() {
  53.       String var1 = this.getName();
  54.       if (var1 == null) {
  55.          throw new IllegalArgumentException("MBeanPermission name cannot be null");
  56.       } else if (var1.equals("")) {
  57.          throw new IllegalArgumentException("MBeanPermission name cannot be empty");
  58.       } else {
  59.          int var2 = var1.indexOf("[");
  60.          if (var2 == -1) {
  61.             this.objectName = ObjectName.WILDCARD;
  62.          } else {
  63.             if (!var1.endsWith("]")) {
  64.                throw new IllegalArgumentException("MBeanPermission: The ObjectName in the target name must be included in square brackets");
  65.             }
  66.  
  67.             try {
  68.                String var3 = var1.substring(var2 + 1, var1.length() - 1);
  69.                if (var3.equals("")) {
  70.                   this.objectName = ObjectName.WILDCARD;
  71.                } else if (var3.equals("-")) {
  72.                   this.objectName = null;
  73.                } else {
  74.                   this.objectName = new ObjectName(var3);
  75.                }
  76.             } catch (MalformedObjectNameException var5) {
  77.                throw new IllegalArgumentException("MBeanPermission: The target name does not specify a valid ObjectName");
  78.             }
  79.  
  80.             var1 = var1.substring(0, var2);
  81.          }
  82.  
  83.          int var6 = var1.indexOf("#");
  84.          if (var6 == -1) {
  85.             this.setMember("*");
  86.          } else {
  87.             String var4 = var1.substring(var6 + 1);
  88.             this.setMember(var4);
  89.             var1 = var1.substring(0, var6);
  90.          }
  91.  
  92.          this.setClassName(var1);
  93.       }
  94.    }
  95.  
  96.    private void initName(String var1, String var2, ObjectName var3) {
  97.       this.setClassName(var1);
  98.       this.setMember(var2);
  99.       this.objectName = var3;
  100.    }
  101.  
  102.    private void setClassName(String var1) {
  103.       if (var1 != null && !var1.equals("-")) {
  104.          if (!var1.equals("") && !var1.equals("*")) {
  105.             if (var1.endsWith(".*")) {
  106.                this.classNamePrefix = var1.substring(0, var1.length() - 1);
  107.                this.classNameExactMatch = false;
  108.             } else {
  109.                this.classNamePrefix = var1;
  110.                this.classNameExactMatch = true;
  111.             }
  112.          } else {
  113.             this.classNamePrefix = "";
  114.             this.classNameExactMatch = false;
  115.          }
  116.       } else {
  117.          this.classNamePrefix = null;
  118.          this.classNameExactMatch = false;
  119.       }
  120.  
  121.    }
  122.  
  123.    private void setMember(String var1) {
  124.       if (var1 != null && !var1.equals("-")) {
  125.          if (var1.equals("")) {
  126.             this.member = "*";
  127.          } else {
  128.             this.member = var1;
  129.          }
  130.       } else {
  131.          this.member = null;
  132.       }
  133.  
  134.    }
  135.  
  136.    public MBeanPermission(String var1, String var2) {
  137.       super(var1);
  138.       this.parseName();
  139.       this.actions = var2;
  140.       this.parseActions();
  141.    }
  142.  
  143.    public MBeanPermission(String var1, String var2, ObjectName var3, String var4) {
  144.       super(makeName(var1, var2, var3));
  145.       this.initName(var1, var2, var3);
  146.       this.actions = var4;
  147.       this.parseActions();
  148.    }
  149.  
  150.    private static String makeName(String var0, String var1, ObjectName var2) {
  151.       StringBuffer var3 = new StringBuffer();
  152.       if (var0 == null) {
  153.          var0 = "-";
  154.       }
  155.  
  156.       var3.append(var0);
  157.       if (var1 == null) {
  158.          var1 = "-";
  159.       }
  160.  
  161.       var3.append("#" + var1);
  162.       if (var2 == null) {
  163.          var3.append("[-]");
  164.       } else {
  165.          var3.append("[").append(var2.getCanonicalName()).append("]");
  166.       }
  167.  
  168.       return var3.length() == 0 ? "*" : var3.toString();
  169.    }
  170.  
  171.    public String getActions() {
  172.       if (this.actions == null) {
  173.          this.actions = getActions(this.mask);
  174.       }
  175.  
  176.       return this.actions;
  177.    }
  178.  
  179.    private static String getActions(int var0) {
  180.       StringBuffer var1 = new StringBuffer();
  181.       boolean var2 = false;
  182.       if ((var0 & 1) == 1) {
  183.          var2 = true;
  184.          var1.append("addNotificationListener");
  185.       }
  186.  
  187.       if ((var0 & 2) == 2) {
  188.          if (var2) {
  189.             var1.append(',');
  190.          } else {
  191.             var2 = true;
  192.          }
  193.  
  194.          var1.append("getAttribute");
  195.       }
  196.  
  197.       if ((var0 & 4) == 4) {
  198.          if (var2) {
  199.             var1.append(',');
  200.          } else {
  201.             var2 = true;
  202.          }
  203.  
  204.          var1.append("getClassLoader");
  205.       }
  206.  
  207.       if ((var0 & 8) == 8) {
  208.          if (var2) {
  209.             var1.append(',');
  210.          } else {
  211.             var2 = true;
  212.          }
  213.  
  214.          var1.append("getClassLoaderFor");
  215.       }
  216.  
  217.       if ((var0 & 16) == 16) {
  218.          if (var2) {
  219.             var1.append(',');
  220.          } else {
  221.             var2 = true;
  222.          }
  223.  
  224.          var1.append("getClassLoaderRepository");
  225.       }
  226.  
  227.       if ((var0 & 32) == 32) {
  228.          if (var2) {
  229.             var1.append(',');
  230.          } else {
  231.             var2 = true;
  232.          }
  233.  
  234.          var1.append("getDomains");
  235.       }
  236.  
  237.       if ((var0 & 64) == 64) {
  238.          if (var2) {
  239.             var1.append(',');
  240.          } else {
  241.             var2 = true;
  242.          }
  243.  
  244.          var1.append("getMBeanInfo");
  245.       }
  246.  
  247.       if ((var0 & 128) == 128) {
  248.          if (var2) {
  249.             var1.append(',');
  250.          } else {
  251.             var2 = true;
  252.          }
  253.  
  254.          var1.append("getObjectInstance");
  255.       }
  256.  
  257.       if ((var0 & 256) == 256) {
  258.          if (var2) {
  259.             var1.append(',');
  260.          } else {
  261.             var2 = true;
  262.          }
  263.  
  264.          var1.append("instantiate");
  265.       }
  266.  
  267.       if ((var0 & 512) == 512) {
  268.          if (var2) {
  269.             var1.append(',');
  270.          } else {
  271.             var2 = true;
  272.          }
  273.  
  274.          var1.append("invoke");
  275.       }
  276.  
  277.       if ((var0 & 1024) == 1024) {
  278.          if (var2) {
  279.             var1.append(',');
  280.          } else {
  281.             var2 = true;
  282.          }
  283.  
  284.          var1.append("isInstanceOf");
  285.       }
  286.  
  287.       if ((var0 & 2048) == 2048) {
  288.          if (var2) {
  289.             var1.append(',');
  290.          } else {
  291.             var2 = true;
  292.          }
  293.  
  294.          var1.append("queryMBeans");
  295.       }
  296.  
  297.       if ((var0 & 4096) == 4096) {
  298.          if (var2) {
  299.             var1.append(',');
  300.          } else {
  301.             var2 = true;
  302.          }
  303.  
  304.          var1.append("queryNames");
  305.       }
  306.  
  307.       if ((var0 & 8192) == 8192) {
  308.          if (var2) {
  309.             var1.append(',');
  310.          } else {
  311.             var2 = true;
  312.          }
  313.  
  314.          var1.append("registerMBean");
  315.       }
  316.  
  317.       if ((var0 & 16384) == 16384) {
  318.          if (var2) {
  319.             var1.append(',');
  320.          } else {
  321.             var2 = true;
  322.          }
  323.  
  324.          var1.append("removeNotificationListener");
  325.       }
  326.  
  327.       if ((var0 & 'ËÄÄ') == 32768) {
  328.          if (var2) {
  329.             var1.append(',');
  330.          } else {
  331.             var2 = true;
  332.          }
  333.  
  334.          var1.append("setAttribute");
  335.       }
  336.  
  337.       if ((var0 & 65536) == 65536) {
  338.          if (var2) {
  339.             var1.append(',');
  340.          } else {
  341.             var2 = true;
  342.          }
  343.  
  344.          var1.append("unregisterMBean");
  345.       }
  346.  
  347.       return var1.toString();
  348.    }
  349.  
  350.    public int hashCode() {
  351.       return this.getName().hashCode() + this.getActions().hashCode();
  352.    }
  353.  
  354.    private static int getMask(String param0) {
  355.       // $FF: Couldn't be decompiled
  356.    }
  357.  
  358.    public boolean implies(Permission var1) {
  359.       if (!(var1 instanceof MBeanPermission)) {
  360.          return false;
  361.       } else {
  362.          MBeanPermission var2 = (MBeanPermission)var1;
  363.          if ((this.mask & 2048) == 2048) {
  364.             if (((this.mask | 4096) & var2.mask) != var2.mask) {
  365.                return false;
  366.             }
  367.          } else if ((this.mask & var2.mask) != var2.mask) {
  368.             return false;
  369.          }
  370.  
  371.          if (var2.classNamePrefix != null) {
  372.             if (this.classNamePrefix == null) {
  373.                return false;
  374.             }
  375.  
  376.             if (this.classNameExactMatch) {
  377.                if (!var2.classNameExactMatch) {
  378.                   return false;
  379.                }
  380.  
  381.                if (!var2.classNamePrefix.equals(this.classNamePrefix)) {
  382.                   return false;
  383.                }
  384.             } else if (!var2.classNamePrefix.startsWith(this.classNamePrefix)) {
  385.                return false;
  386.             }
  387.          }
  388.  
  389.          if (var2.member != null) {
  390.             if (this.member == null) {
  391.                return false;
  392.             }
  393.  
  394.             if (!this.member.equals("*") && !this.member.equals(var2.member)) {
  395.                return false;
  396.             }
  397.          }
  398.  
  399.          if (var2.objectName != null) {
  400.             if (this.objectName == null) {
  401.                return false;
  402.             }
  403.  
  404.             if (!this.objectName.apply(var2.objectName) && !this.objectName.equals(var2.objectName)) {
  405.                return false;
  406.             }
  407.          }
  408.  
  409.          return true;
  410.       }
  411.    }
  412.  
  413.    public boolean equals(Object var1) {
  414.       if (var1 == this) {
  415.          return true;
  416.       } else if (!(var1 instanceof MBeanPermission)) {
  417.          return false;
  418.       } else {
  419.          MBeanPermission var2 = (MBeanPermission)var1;
  420.          return this.mask == var2.mask && this.getName().equals(var2.getName());
  421.       }
  422.    }
  423.  
  424.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  425.       var1.defaultReadObject();
  426.       this.parseName();
  427.       this.parseActions();
  428.    }
  429. }
  430.